#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "uthash.h"

/**
 * Definition for a binary tree node.
 */
struct TreeNode {
	int val;
	struct TreeNode* left;
	struct TreeNode* right;
};
typedef struct TreeNode tree_node, *tree_node_ptr;

int sumNumbers(struct TreeNode* root);

void dfs(tree_node_ptr root, char* str, int size);

int main()
{
	return 0;
}

int res;
int sumNumbers(struct TreeNode* root)
{
	res = 0;
	char str[12] = { 0 };

	if (root) dfs(root, str, 0);

	return res;
}

void dfs(tree_node_ptr root, char* str, int size)
{
	str[size] = root->val + '0';

	if (!root->left && !root->right) {
		res += atoi(str);
	} else {
		if (root->left)  dfs(root->left, str, size + 1);
		if (root->right) dfs(root->right, str, size + 1);
	}

	str[size] = '\0';
}
